<template>
    <div>
        <div class="operarea" v-if="activeName !== 'clothes' && activeName !== 'size'">
            <div class="seach">
                <el-input v-model="seachForm.name" :placeholder="$t('name')" clearable size="mini"></el-input>
                <el-button size="mini" icon="el-icon-search" @click="getData"></el-button>
            </div>
            <div class="btnList">
                <el-button size="mini" @click="showAddDlog">{{$t('add')}}</el-button>
            </div>
        </div>
        <div class="operarea" v-if="activeName == 'clothes'">
            <div class="seach">
                <el-input v-model="clothesForm.cloLength" :placeholder="$t('clolength')" clearable size="mini"></el-input>
                <el-button size="mini" icon="el-icon-search" @click="seachKaftenLength"></el-button>
            </div>
            <div class="btnList">
                <el-button size="mini" @click="addClothesDialogVisible = true">{{$t('add')}}</el-button>
            </div>
        </div>
        <div class="operarea" v-if="activeName == 'size'">
            <div class="seach">
                <el-input v-model="getSizeForm.cloSize" :placeholder="$t('size')" clearable size="mini"></el-input>
                <el-button size="mini" icon="el-icon-search" @click="seachSizeData"></el-button>
            </div>
            <div class="btnList">
                <el-button size="mini" @click="addSizeDialogVisible = true">{{$t('add')}}</el-button>
            </div>
        </div>
        <el-tabs v-model="seachForm.type" type="card" @tab-click="saveActive">
            <el-tab-pane :label="$t('collartype')" name="kftPattern">
                <el-card class="cardBox">
                    <el-breadcrumb separator="/">
                        <el-breadcrumb-item>kaften</el-breadcrumb-item>
                        <el-breadcrumb-item>版型</el-breadcrumb-item>
                    </el-breadcrumb>
                    <el-table style="width: 100%" :data="collarTab" stripe v-adaptive="{bottomOffset: 85}" height="100">
                        <el-table-column prop="name" :label="$t('name')">
                        </el-table-column>
                        <el-table-column prop="bh" :label="$t('serialnumber')">
                        </el-table-column>
                        <el-table-column :label="$t('image')">
                            <template v-slot="scope">
                                <el-image v-if="scope.row.imgUrl !== '' && scope.row.imgUrl !== null" :src="scope.row.imgUrl" class="feelImg" :preview-src-list="getSrcList(scope.$index)"></el-image>
                            </template>
                        </el-table-column>
                        <el-table-column prop="address" width="150" :label="$t('operation')">
                            <template v-slot="scope">
                                <el-button @click.stop="showModifyData(scope.row)" size="mini">编辑</el-button>
                                <el-button @click.stop="showDelData(scope.row.uuid)" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                        small
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :pager-count="11"
                        :current-page.sync="seachForm.pageNo"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="seachForm.pageSize"
                        layout="sizes, prev, pager, next"
                        :total="clothesTotal">
                    </el-pagination>
                </el-card>
            </el-tab-pane>
            <el-tab-pane :label="$t('clotheslength')" name="clothes">
                <el-card class="cardBox">
                    <el-breadcrumb separator="/">
                        <el-breadcrumb-item>kaften</el-breadcrumb-item>
                        <el-breadcrumb-item>衣长</el-breadcrumb-item>
                    </el-breadcrumb>
                    <el-table style="width: 100%" :data="clothesTab" stripe v-adaptive="{bottomOffset: 85}" height="100">
                        <el-table-column prop="cloLength" :label="$t('clolength')">
                        </el-table-column>
                        <el-table-column prop="address" width="150" :label="$t('operation')">
                            <template v-slot="scope">
                                <el-button @click.stop="showModifyClothes(scope.row)" size="mini">编辑</el-button>
                                <el-button @click.stop="showDelClothes(scope.row.uuid)" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                        small
                        @size-change="handleSizeClothesChange"
                        @current-change="handleClothesCurrentChange"
                        :pager-count="11"
                        :current-page.sync="clothesForm.pageNo"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="clothesForm.pageSize"
                        layout="sizes, prev, pager, next"
                        :total="clothesTotal">
                    </el-pagination>
                </el-card>
            </el-tab-pane>
            <el-tab-pane :label="$t('sleevetype')" name="kftSlv">
                <el-card class="cardBox">
                    <el-breadcrumb separator="/">
                        <el-breadcrumb-item>kaften</el-breadcrumb-item>
                        <el-breadcrumb-item>袖型</el-breadcrumb-item>
                    </el-breadcrumb>
                    <el-table style="width: 100%" :data="sleeveTab" stripe v-adaptive="{bottomOffset: 85}" height="100">
                        <el-table-column prop="name" :label="$t('name')">
                        </el-table-column>
                        <el-table-column prop="bh" :label="$t('serialnumber')">
                        </el-table-column>
                        <el-table-column :label="$t('image')">
                            <template v-slot="scope">
                                <el-image v-if="scope.row.imgUrl !== '' && scope.row.imgUrl !== null" :src="scope.row.imgUrl" class="feelImg" :preview-src-list="getSrcList(scope.$index)"></el-image>
                            </template>
                        </el-table-column>
                        <el-table-column prop="address" width="150" :label="$t('operation')">
                            <template v-slot="scope">
                                <el-button @click.stop="showModifyData(scope.row)" size="mini">编辑</el-button>
                                <el-button @click.stop="showDelData(scope.row.uuid)" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                        small
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :pager-count="11"
                        :current-page.sync="seachForm.pageNo"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="seachForm.pageSize"
                        layout="sizes, prev, pager, next"
                        :total="clothesTotal">
                    </el-pagination>
                </el-card>
            </el-tab-pane>
            <el-tab-pane :label="$t('pocket')" name="kftPkt">
                <el-card class="cardBox">
                    <el-breadcrumb separator="/">
                        <el-breadcrumb-item>kaften</el-breadcrumb-item>
                        <el-breadcrumb-item>口袋</el-breadcrumb-item>
                    </el-breadcrumb>
                    <el-table style="width: 100%" :data="pocketTab" stripe v-adaptive="{bottomOffset: 85}" height="100">
                        <el-table-column prop="name" :label="$t('name')">
                        </el-table-column>
                        <el-table-column prop="bh" :label="$t('serialnumber')">
                        </el-table-column>
                        <el-table-column :label="$t('image')">
                            <template v-slot="scope">
                                <el-image v-if="scope.row.imgUrl !== '' && scope.row.imgUrl !== null" :src="scope.row.imgUrl" class="feelImg" :preview-src-list="getSrcList(scope.$index)"></el-image>
                            </template>
                        </el-table-column>
                        <el-table-column prop="address" width="150" :label="$t('operation')">
                            <template v-slot="scope">
                                <el-button @click.stop="showModifyData(scope.row)" size="mini">编辑</el-button>
                                <el-button @click.stop="showDelData(scope.row.uuid)" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                        small
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :pager-count="11"
                        :current-page.sync="seachForm.pageNo"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="seachForm.pageSize"
                        layout="sizes, prev, pager, next"
                        :total="clothesTotal">
                    </el-pagination>
                </el-card>
            </el-tab-pane>
            <el-tab-pane :label="$t('size')" name="size">
                <el-card class="cardBox">
                    <el-breadcrumb separator="/">
                        <el-breadcrumb-item>kaften</el-breadcrumb-item>
                        <el-breadcrumb-item>尺码</el-breadcrumb-item>
                    </el-breadcrumb>
                    <el-table style="width: 100%" :data="sizeTab" stripe v-adaptive="{bottomOffset: 85}" height="100">
                        <el-table-column prop="cloSize" :label="$t('size')">
                        </el-table-column>
                        <el-table-column prop="address" width="150" :label="$t('operation')">
                            <template v-slot="scope">
                                <el-button @click.stop="showModifySize(scope.row)" size="mini">编辑</el-button>
                                <el-button @click.stop="showDelSize(scope.row.uuid)" size="mini">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                        small
                        @size-change="handleCurrentSizeChange"
                        @current-change="handleCurrentNoChange"
                        :pager-count="11"
                        :current-page.sync="getSizeForm.pageNo"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="getSizeForm.pageSize"
                        layout="sizes, prev, pager, next"
                        :total="clothesTotal">
                    </el-pagination>
                </el-card>
            </el-tab-pane>
        </el-tabs>
        <!-- 领型 -->
        <el-dialog :title="$t('add')" :visible.sync="addDataDialogVisible" width="500px" class="smallDlog" :close-on-click-modal="false" @close="addDataDlogClose(addDataDataForm)">
            <el-form :model="addDataDataForm" :rules="addDataRules" :ref="addDataDataForm" class="motuoForm">
                <el-form-item :label="$t('name')" label-width="70px" prop="name">
                    <el-input v-model="addDataDataForm.name" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
                <el-form-item :label="$t('serialnumber')" label-width="70px" prop="bh">
                    <el-input v-model="addDataDataForm.bh" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
                <el-form-item :label="$t('image')" label-width="70px" prop="imgUrl">
                    <el-upload class="upload-demo" action="/sys/image/uploadImage" :on-success="handleImg" :on-remove="handleRemove" :limit="1" :on-exceed="scotland" :file-list="fileList" list-type="picture" ref="sunsetstrip">
                        <el-button size="small" type="primary">点击上传</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传jpg/png/jepg文件，且不超过5MB</div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addDataDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="addDataData(addDataDataForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <el-dialog :title="$t('modify')" :visible.sync="modifyDataDialogVisible" width="500px" class="smallDlog" :close-on-click-modal="false" @close="modifyDataDlogClose(modifyDataDataForm)">
            <el-form :model="modifyDataDataForm" :rules="modifyDataRules" :ref="modifyDataDataForm" class="motuoForm">
                <el-form-item :label="$t('name')" label-width="70px" prop="name">
                    <el-input v-model="modifyDataDataForm.name" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
                <el-form-item :label="$t('serialnumber')" label-width="70px" prop="bh">
                    <el-input v-model="modifyDataDataForm.bh" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
                <el-form-item :label="$t('image')" label-width="70px" prop="imgUrl">
                    <el-upload class="upload-demo" action="/sys/image/uploadImage" :on-success="handleImg" :on-remove="handleRemove" :limit="1" :on-exceed="scotland" :file-list="fileList" list-type="picture" ref="sunsetstrip">
                        <el-button size="small" type="primary">点击上传</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传jpg/png/jepg文件，且不超过5MB</div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="modifyDataDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="modifyDataData(modifyDataDataForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <el-dialog :title="$t('hint')" :visible.sync="delDataDialogVisible" width="420px" class="smallDlog" :close-on-click-modal="false">
            <span>{{$t('confirmdel')}}</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delDataDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="delDataData">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <!-- 衣长 -->
        <el-dialog :title="$t('add')" :visible.sync="addClothesDialogVisible" width="500px" class="smallDlog" :close-on-click-modal="false" @close="addClothesDataDlogClose(addKatenClothesForm)">
            <el-form :model="addKatenClothesForm" :rules="addKatenClothesRules" :ref="addKatenClothesForm" class="motuoForm">
                <el-form-item :label="$t('clolength')" label-width="70px" prop="cloLength">
                    <el-input v-model="addKatenClothesForm.cloLength" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addClothesDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="addClothesData(addKatenClothesForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <el-dialog :title="$t('modify')" :visible.sync="modifyClothesDialogVisible" width="500px" class="smallDlog" :close-on-click-modal="false" @close="modifyClothesDataDlogClose(modifyClothesForm)">
            <el-form :model="modifyClothesForm" :rules="modifyClothesDataRules" :ref="modifyClothesForm" class="motuoForm">
                <el-form-item :label="$t('clolength')" label-width="70px" prop="cloLength">
                    <el-input v-model="modifyClothesForm.cloLength" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="modifyClothesDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="modifyClothesData(modifyClothesForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <el-dialog :title="$t('hint')" :visible.sync="delClothesDialogVisible" width="420px" class="smallDlog" :close-on-click-modal="false">
            <span>{{$t('confirmdel')}}</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delClothesDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="delKaftenClothes">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <!-- size -->
        <el-dialog :title="$t('add')" :visible.sync="addSizeDialogVisible" width="500px" class="smallDlog" :close-on-click-modal="false" @close="addSizeDataDlogClose(addKaftenSizeForm)">
            <el-form :model="addKaftenSizeForm" :rules="addKatenSizeRules" :ref="addKaftenSizeForm" class="motuoForm">
                <el-form-item :label="$t('size')" label-width="70px" prop="cloSize">
                    <el-input v-model="addKaftenSizeForm.cloSize" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addSizeDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="addSizeData(addKaftenSizeForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <el-dialog :title="$t('modify')" :visible.sync="modifySizeDialogVisible" width="500px" class="smallDlog" :close-on-click-modal="false" @close="modifySizeDataDlogClose(modifyKaftenSizeForm)">
            <el-form :model="modifyKaftenSizeForm" :rules="modifyKatenSizeRules" :ref="modifyKaftenSizeForm" class="motuoForm">
                <el-form-item :label="$t('size')" label-width="70px" prop="cloSize">
                    <el-input v-model="modifyKaftenSizeForm.cloSize" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="modifySizeDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="modifySizeData(modifyKaftenSizeForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <el-dialog :title="$t('hint')" :visible.sync="delSizeDialogVisible" width="420px" class="smallDlog" :close-on-click-modal="false">
            <span>{{$t('confirmdel')}}</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delSizeDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="delKaftenSize">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import {
    getRobesElementAll,
    addRobesElementItem,
    editRobesElementItem,
    deleteRobesElementItem,
    getKaftenLengthList,
    addKaftenLength,
    updateKaftenLength,
    deleteKaftenLength,
    getKaftenSizeList,
    addKaftenSize,
    updateKaftenSize,
    deleteKaftenSize
} from "@/libs/reqlist.js"
export default {
    data () {
        return {
            activeName: '',
            total: 0,
            seachForm: {
                deleteStatus: 0,
                pageNo: 1,
                pageSize: 10,
                name: '',
                bh: '',
                type: 'kftPattern',
                cloType: '1'
            },
            doType: 0,
            imgList: [],
            // 领型
            collarTab: [],
            pocketTab: [],
            sleeveTab: [],
            addDataDialogVisible: false,
            addDataDataForm: {
                name: '',
                bh: '',
                type: '',
                cloType: '1',
                imgUrl: '',
                uuid: ''
            },
            addDataRules: {
                name: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ],
                bh: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ]
            },
            modifyDataDialogVisible: false,
            fileList: [],
            modifyDataDataForm: {
                name: '',
                bh: '',
                type: '',
                cloType: '1',
                imgUrl: ''
            },
            modifyDataRules: {
                name: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ],
                bh: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ]
            },
            delDataDialogVisible: false,
            deleteId: '',
            // 衣长
            clothesTotal: 0,
            clothesForm: {
                pageNo: 1,
                pageSize: 10,
                cloLength: ''
            },
            clothesTab: [],
            addClothesDialogVisible: false,
            addKatenClothesForm: {
                cloLength: ''
            },
            addKatenClothesRules: {
                cloLength: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ]
            },
            modifyClothesDialogVisible: false,
            modifyClothesForm: {
                uuid: '',
                cloLength: ''
            },
            modifyClothesDataRules: {
                cloLength: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ]
            },
            delClothesDialogVisible: false,
            delClothesById: '',
            // 尺寸
            sizeTotal: 0,
            getSizeForm: {
                pageNo: 1,
                pageSize: 10,
                cloSize: ''
            },
            sizeTab: [],
            addSizeDialogVisible: false,
            addKaftenSizeForm: {
                cloSize: ''
            },
            addKatenSizeRules: {
                cloSize: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ]
            },
            modifySizeDialogVisible: false,
            modifyKaftenSizeForm: {
                uuid: '',
                cloSize: ''
            },
            modifyKatenSizeRules: {
                cloSize: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ]
            },
            delSizeDialogVisible: false,
            delSizeById: ''
        }
    },
    methods: {
        saveActive(tab) {
            this.seachForm.pageNo = 1
            this.seachForm.pageSize = 10
            this.seachForm.type = tab.name
            this.activeName = tab.name
            switch (this.activeName) {
                case 'clothes':
                    this.getKaftenLength()
                    break
                case 'size':
                    this.getKaftenSizeData()
                    break
                default:
                    this.seachData()
                    break
            }
            window.sessionStorage.setItem('kaftenAct', this.activeName)
        },
        seachData () {
            this.imgList = []
            getRobesElementAll(this.seachForm).then(res => {
                if (res.data.code === 0) {
                    this.total = res.data.data.hits
                    res.data.data.data.forEach(item => {
                        this.imgList.push(item.imgUrl)
                    })
                    switch (this.seachForm.type) {
                        case 'kftPattern':
                            this.collarTab = res.data.data.data
                            break
                        case 'kftPkt':
                            this.pocketTab = res.data.data.data
                            break
                        case 'kftSlv':
                            this.sleeveTab = res.data.data.data
                            break
                    }
                }
            })
        },
        getData() {
            this.seachForm.pageNo = 1
            this.seachData()
        },
        handleSizeChange (newSize) {
            this.seachForm.pageSize = newSize
            this.seachData()
        },
        handleCurrentChange (newNum) {
            this.seachForm.pageNo = newNum
            this.seachData()
        },
        getSrcList(index) {
            return this.imgList.slice(index).concat(this.imgList.slice(0, index))
        },
        handleImg(res) {
            if (res.code == 0) {
                switch (this.doType) {
                    case 1:
                        this.addDataDataForm.imgUrl = res.data
                        break
                    case 2:
                        this.modifyDataDataForm.imgUrl = res.data
                        break
                }
            }
        },
        handleRemove(file) {
            if (file) {
                switch (this.doType) {
                    case 1:
                        this.fileList = []
                        this.addDataDataForm.imgUrl = ''
                        break
                    case 2:
                        this.fileList = []
                        this.modifyDataDataForm.imgUrl = ''
                        break
                }
            }
        },
        // 上传文件超出个数触发
        scotland() {
            this.$message.warning('只能选择一个文件')
        },
        // 领型
        showAddDlog() {
            this.doType = 1
            this.addDataDialogVisible = true
        },
        addDataDlogClose (form) {
            this.fileList = []
            this.$refs.sunsetstrip.clearFiles()
            this.$refs[form].resetFields()
        },
        addDataData (form) {
            this.addDataDataForm.type = this.seachForm.type
            this.$refs[form].validate(valid => {
                if (!valid) return
                if (this.addDataDataForm.imgUrl == '') return this.$message.warning('请至少选择一张图片上传')
                addRobesElementItem(this.addDataDataForm).then(res => {
                    if (res.data.code === 0) {
                        this.addDataDialogVisible = false
                        this.$message.success(this.$t('sucadd'))
                        this.seachData()
                    }
                })
            })
        },
        showModifyData (data) {
            this.doType = 2
            this.modifyDataDataForm.name = data.name
            this.modifyDataDataForm.bh = data.bh
            this.modifyDataDataForm.type = data.type
            this.modifyDataDataForm.imgUrl = data.imgUrl
            if (data.imgUrl !== '' && data.imgUrl !== null) this.fileList.push({ name: data.name, url: data.imgUrl })
            this.modifyDataDataForm.uuid = data.uuid
            this.modifyDataDialogVisible = true
        },
        modifyDataDlogClose (form) {
            this.fileList = []
            this.$refs.sunsetstrip.clearFiles()
            this.$refs[form].resetFields()
        },
        modifyDataData (form) {
            this.$refs[form].validate(valid => {
                if (!valid) return
                if (this.modifyDataDataForm.imgUrl == '') return this.$message.warning('请至少选择一张图片上传')
                editRobesElementItem(this.modifyDataDataForm).then(res => {
                    if (res.data.code === 0) {
                        this.modifyDataDialogVisible = false
                        this.$message.success(this.$t('modifysuc'))
                        this.seachData()
                    }
                })
            })
        },
        showDelData (uuid) {
            this.deleteId = uuid
            this.delDataDialogVisible = true
        },
        delDataData () {
            deleteRobesElementItem({ uuid: this.deleteId }).then(res => {
                if (res.data.code === 0) {
                    this.delDataDialogVisible = false
                    this.$message.success(this.$t('delsuc'))
                    this.seachData()
                }
            })
        },
        // 衣长
        getKaftenLength() {
            getKaftenLengthList(JSON.stringify(this.clothesForm)).then(res => {
                if (res.data.code == 0) {
                    this.clothesTab = res.data.data.data
                    this.clothesTotal = res.data.data.hits
                }
            })
        },
        seachKaftenLength() {
            this.clothesForm.pageNo = 1
            this.getKaftenLength()
        },
        handleSizeClothesChange (newSize) {
            this.clothesForm.pageSize = newSize
            this.getKaftenLength()
        },
        handleClothesCurrentChange (newNum) {
            this.clothesForm.pageNo = newNum
            this.getKaftenLength()
        },
        addClothesDataDlogClose(form) {
            this.$refs[form].resetFields()
        },
        addClothesData(form) {
            this.$refs[form].validate(valid => {
                if (!valid) return
                addKaftenLength(JSON.stringify(this.addKatenClothesForm)).then(res => {
                    if (res.data.code == 0) {
                        this.addClothesDialogVisible = false
                        this.getKaftenLength()
                        this.$message.success(this.$t('sucadd'))
                    }
                })
            })
        },
        showModifyClothes(item) {
            this.modifyClothesForm.uuid = item.uuid
            this.modifyClothesForm.cloLength = item.cloLength
            this.modifyClothesDialogVisible = true
        },
        modifyClothesDataDlogClose(form) {
            this.$refs[form].resetFields()
        },
        modifyClothesData(form) {
            this.$refs[form].validate(valid => {
                if (!valid) return
                updateKaftenLength(JSON.stringify(this.modifyClothesForm)).then(res => {
                    if (res.data.code == 0) {
                        this.modifyClothesDialogVisible = false
                        this.getKaftenLength()
                        this.$message.success(this.$t('modifysuc'))
                    }
                })
            })
        },
        showDelClothes(id) {
            this.delClothesById = id,
            this.delClothesDialogVisible = true
        },
        delKaftenClothes() {
            deleteKaftenLength(JSON.stringify({ uuid: this.delClothesById })).then(res => {
                if (res.data.code == 0) {
                    this.delClothesDialogVisible = false
                    this.getKaftenLength()
                    this.$message.success(this.$t('delsuc'))
                }
            })
        },
        // 尺寸
        getKaftenSizeData() {
            getKaftenSizeList(JSON.stringify(this.getSizeForm)).then(res => {
                if (res.data.code == 0) {
                    this.sizeTotal = res.data.data.hits
                    this.sizeTab = res.data.data.data
                }
            })
        },
        handleCurrentSizeChange (newSize) {
            this.getSizeForm.pageSize = newSize
            this.getKaftenSizeData()
        },
        handleCurrentNoChange (newNum) {
            this.getSizeForm.pageNo = newNum
            this.getKaftenSizeData()
        },
        seachSizeData() {
            this.getSizeForm.pageNo = 1
            this.getKaftenSizeData()
        },
        addSizeDataDlogClose(form) {
            this.$refs[form].resetFields()
        },
        addSizeData(form) {
            this.$refs[form].validate(valid => {
                if (!valid) return
                addKaftenSize(JSON.stringify(this.addKaftenSizeForm)).then(res => {
                    if (res.data.code == 0) {
                        this.addSizeDialogVisible = false
                        this.getKaftenSizeData()
                        this.$message.success(this.$t('sucadd'))
                    }
                })
            })
        },
        showModifySize(item) {
            this.modifyKaftenSizeForm.uuid = item.uuid
            this.modifyKaftenSizeForm.cloSize = item.cloSize
            this.modifySizeDialogVisible = true
        },
        modifySizeDataDlogClose(form) {
            this.$refs[form].resetFields()
        },
        modifySizeData(form) {
            this.$refs[form].validate(valid => {
                if (!valid) return
                updateKaftenSize(JSON.stringify(this.modifyKaftenSizeForm)).then(res => {
                    if (res.data.code == 0) {
                        this.modifySizeDialogVisible = false
                        this.getKaftenSizeData()
                        this.$message.success(this.$t('modifysuc'))
                    }
                })
            })
        },
        showDelSize(id) {
            this.delSizeById = id
            this.delSizeDialogVisible = true
        },
        delKaftenSize() {
            deleteKaftenSize(JSON.stringify({ uuid: this.delSizeById })).then(res => {
                if (res.data.code == 0) {
                    this.delSizeDialogVisible = false
                    this.getKaftenSizeData()
                    this.$message.success(this.$t('delsuc'))
                }
            })
        }
    },
    mounted () {
        this.seachData()
    }
}
</script>

<style lang="less" scoped>
@import './kaften.less';
</style>
